home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGSCAL / TBUTIL1.LZH / UT-MOD04.INC < prev    next >
Text File  |  1984-08-30  |  3KB  |  70 lines

  1. procedure Hmenu(C,R:integer;Status:str255; var Ch: char);
  2. var
  3.   MenuLen     : integer;
  4.   Menustr     : string[79];
  5.   MenuLtrs    : string[12];
  6.   I           : array[1..20] of string[8];  { menu Items }
  7.   counter     : integer;
  8. begin
  9.   Counter := 0; Set_Cap_Num(' ',' ',' ');
  10.  
  11.        {**** build menu Item and Prompt arrays ****}
  12.   repeat
  13.     Counter := Counter + 1;
  14.        {** locate menu Item in Prompt string and assign it to I[Counter **}
  15.     I[Counter] := Copy(P[Counter],1,Pos('.',P[Counter])-1);
  16.        {** trim trailing blanks , if any from newly formed menu Item ** }
  17.     I[Counter] := Copy(I[Counter],1,Pos(' ',I[Counter]+' ')-1);
  18.        {** delete menu Item from from Prompt string **}
  19.     Delete(P[Counter],1,Pos('.',P[Counter]));
  20.   until (P[Counter] = ' ') or (P[Counter] = '');
  21.        {**** last menu Item and Prompt completed ****}
  22.  
  23.   Menulen  := Counter-1;
  24.   MenuStr  := '';
  25.   MenuLtrs := '';
  26.   for Counter := 1 to Menulen do
  27.     begin
  28.         {** the  + ' '  below controls space between menu items **}
  29.       MenuStr := MenuStr  + I[Counter] + '  ';
  30.       MenuLtrs:= MenuLtrs + Copy(I[Counter],1,1);
  31.     end;
  32.  
  33. {.pa}
  34.         {**** begin display of Hmenu ****}
  35.   Counter := 1;
  36.         {** write Status string in top right corner **}
  37.   gotoXY(1,1); clreol; GotoXY(79-length(status),1);
  38.   textbackground(15);textcolor( 0);write(status);
  39.   textbackground( 0);textcolor(15); writeln; clreol;
  40.   lowvideo;
  41.   repeat
  42.     GotoXY(C,R);
  43.     lowvideo;
  44.     writeln (Menustr); {** Write menu choices string in low video **}
  45.     clreol;
  46.        {** find location for and write highlighted menu choice **}
  47.     GotoXY((C-1) + pos(I[counter],MenuStr),R);
  48.     textbackground(15);textcolor( 0);write(I[Counter]);
  49.     textbackground( 0);textcolor(15);
  50.         {** write Prompt for highlighted Item **}
  51.     GoToXY(C,R+1); clreol; writeln ( P[Counter] );
  52.     GotoXY(80,1);
  53.         {**** get keyboard input ****}
  54.     Read(kbd,Ch);
  55.     if KeyPressed then Ck_edit_key(Ch);
  56.     Ch := UpCase(Ch);
  57.     case Ch of
  58.       #13       : Ch      := Copy(MenuLtrs,Counter,1);
  59.       ^D,^E,#32 : Counter := Counter + 1;
  60.       ^S,^X     : Counter := Counter - 1;
  61.       ^G        : Counter := 1;
  62.       ^O        : Counter := MenuLen;
  63.     end; {case Ch}
  64.     if Pos(Ch,MenuLtrs) <> 0 then Counter := Pos(Ch,MenuLtrs)
  65.      else if not (Ch in [#13,^D,^E,#32,^S,^X,^G,^O]) then beep(350,200);
  66.     if Counter < 1  then Counter := MenuLen;
  67.     if Counter > MenuLen  then Counter := 1;
  68.   until Pos(Ch,MenuLtrs) <> 0;
  69.   lowvideo;
  70.  end;